home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1999 November / SOTMC_Nov1999-Ultimate.iso / mac / REALbasic ƒ / Examples / Techniques / Interface Inheritance / Read Me < prev   
Encoding:
Text File  |  1999-04-27  |  1.6 KB  |  15 lines  |  [ttro/ttxt]

  1. Interface Inheritance
  2. By Geoff Perlman
  3.  
  4. Introduction
  5. There are times when different classes will need to do bascially the same thing but present themselves or their data in a slight different way. The concept of interface inheiritance solves this problem by allowing you to define a set of methods that each class will then implement and abstract the code that uses these classes from having to know anything about that implementation.
  6.  
  7. Explaination
  8. This example shows three different interface controls that all display the same data but in different ways. If you want to find and then select some specific piece of data from any of these controls, you will need a Find method that you can pass the text you wish to find. In this example, all three controls have a Find method and are passed the same parameter. The Find method and parameter are defined in the MyFindInListInterface class. The MyListBox, MyPopup and MyEditfield classes all support the MyFindInListInterface class. So the code for calling each of their Find methods is quite simple. The FindIt method of a main window is called as follows:
  9.  
  10. Sub Findit(findValue as String, source as MyFindInListInterface)
  11.   dim row as integer
  12.   source.selectRow source.find(findValue)
  13. End Sub
  14.  
  15. As long as the class you are passing as the source supports the MyFindInListInterface then it must have a Find method (as defined by the MyFindInListInterface Interface class) so the code above can call it. Each class that supports the MyFindInListInterface Interface class may implement its Find method differently, but the interface is the same regardless. Each calls the method the same thing and uses the same parameters.